package com.yswy.backstage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yswy.backstage.service.AppProjectService;
import com.yswy.domain.entity.AppProject;
import com.yswy.domain.entity.PackageVersion;
import com.yswy.domain.entity.user.User;
import com.yswy.domain.vo.dto.BaseFilter;
import com.yswy.domain.vo.gld.addOrUpate.AppProjectAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.PackageVersionAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.base.BaseReqVO;
import com.yswy.domain.vo.gld.search.PackageVersionSearch;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

import java.util.List;

import static com.yswy.backstage.utils.GldTokenUtils.getUser;
import static com.yswy.backstage.utils.GldTokenUtils.getUserId;


@RestController
@RequestMapping("/appProject")
@Api(tags = "项目管理")
public class AppProjectController {
    @Autowired
    private AppProjectService appProjectService;

    @PostMapping("/ListAppProject")
    @ApiOperation(value = "项目列表")
    public Page<AppProject> ListAppProject(@RequestBody  BaseFilter req, HttpServletRequest request) {
        return appProjectService.ListAppProject(req);
    }

    @PostMapping("/addAppProject")
    @ApiOperation(value = "添加或修改项目")
    public void addAppProject(@RequestBody @Validated(BaseReqVO.CREATE.class) AppProjectAddOrUpdate req, HttpServletRequest request) {
        appProjectService.addAppProject(req);
    }


    @GetMapping("/delAppProject")
    @ApiOperation(value = "删除项目")
    public void delAppProject(@RequestParam(value = "projectId") Long projectId, HttpServletRequest request) {
        appProjectService.delAppProject(projectId);
    }


    @GetMapping("/listAppProject")
    @ApiOperation(value = "获取用户绑定的项目")
    public List<AppProject> listAppProject(HttpServletRequest request) {
        return appProjectService.listAppProject();
    }
}
